<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->url->theme.'script/settings.js'); ?>
<?php echo CHtml::link(Yii::t('main','add'), Yii::app()->createUrl('admin/settings/create'),array(
    'onClick'=>'Setting.create($(this).attr("href")); return false;',
    'class'=>'submit-green',
)); ?>

<div id="settings-table">
    <?php $this->widget('zii.widgets.grid.CGridView', array(
        'dataProvider'=>$dataProvider,
        'ajaxUpdate'=>true,
        'emptyText'=>Yii::t('settings','noSetting'),
        'showTableOnEmpty'=>false,
        'selectableRows'=>1,
        //'selectionChanged'=>'function(id){ location.href="'.Yii::app()->createUrl('admin/settings/view').'&id="+$.fn.yiiGridView.getSelection(id);}',
        //'sortableAttributes'=>array('id','model','quantity','price'),
        'pager'=>array(
            //'class'=>'CLinkPager',
            'header'=>false,
            //'cssFile'=>Yii::app()->request->baseUrl.'/css/style.css',
            //'htmlOptions'=>array('class'=>'left_content'),
        ),
        'htmlOptions'=>array(
            //'class'=>'specpredlog',
            //'cssFile'=>Yii::app()->request->baseUrl.'/css/style.css',
        ),
        'columns'=>array(

            array(
                'class'=>'CButtonColumn',
                'deleteConfirmation'=>Yii::t('settings','confirmDelete',array('{setting}'=>$data->name)),
                'template'=>'{view}{delete}',
                'htmlOptions'=>array(

                ),

                'buttons'=>array(
                    'delete'=>array(
                        'label'=>Yii::t('main','remove'),
                        'url'=>function($data){ return Yii::app()->createUrl('admin/settings/delete',array('id'=>$data->id)); },
                        //'click'=>function($data){ echo 'return confirm("'.Yii::t('settings','confirmDelete',array('{setting}'=>$data->name)).'");'; },
                        'options'=>array(
                            //'onClick'=>function($data){ return 'return confirm("'.Yii::t('settings','confirmDelete',array('{setting}'=>$data->name)).'");'; },
                            /*'ajax'=>array(
                                'type'=>'get',
                                'url'=>"js:$(this).attr('href')",
                                'update'=>'#settings-table',
                            ),*/
                        ),
                    ),
                    'view'=>array(
                        'label'=>Yii::t('base','show'),
                        'url'=>function($data){ return Yii::app()->createUrl('admin/settings/view',array('id'=>$data->id)); },
                        'options'=>array(
                            'ajax'=>array(
                                'type'=>'POST',
                                'url'=>"js:$(this).attr('href')",
                                'update'=>'#new-item',
                            ),
                            'onClick'=>'Main.openPopup($("#new-item"));',
                        ),
                    ),
                ),
            ),

            array(
                'name'=>Yii::t('base','id'),
                'value'=>function($data){ return $data->id; },
                'sortable'=>true,
                'filter'=>false,
            ),
            array(
                'name'=>Yii::t('settings','name'),
                'value'=>function($data){ return $data->name; },
                'sortable'=>true,
                'filter'=>false,
            ),
            array(
                'name'=>Yii::t('settings','key'),
                'value'=>function($data){ return $data->key; },
                'sortable'=>true,
                'filter'=>false,
            ),
            array(
                'name'=>Yii::t('settings','value'),
                'value'=>function($data){ return $data->value; },
                'sortable'=>true,
                'filter'=>false,
                'type'=>'raw',
            ),
            array(
                'name'=>Yii::t('settings','description'),
                'value'=>function($data){ return $data->description; },
                'sortable'=>true,
                'filter'=>false,
            ),
        ),
    )); ?>
</div>